<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp" %>
<div class="container-fluid am-margin-top">
    <form id="optAuthForm">
        <input type="hidden" name="id"/>
        <input type="hidden" name="funcPointId"/>
        <div class="form-group">
            <label for="name">编码英文前缀</label>
            <input type="text" name="code" class="form-control" placeholder="自动帮你加上'_'">
        </div>
        <div class="form-group">
            <label for="name">名称中文后缀</label>
            <input type="text" name="name" class="form-control">
        </div>
        <div class="form-group">
            <a href="javascript:void(0)" id="optAuthSaveBt"  class="btn btn-primary pull-right">保存</a>
        </div>
    </form>
</div>
<script type="text/javascript">

    $(function () {
        var id = '${param.id}';
        var funcPointId = '${param.funcPointId}';
        $("#optAuthForm").find("input[name=funcPointId]").val(funcPointId);
        var realName = [
			{code: "_VIEW", name: "查询"},
            {code: "_ADD", name: "添加"},
            {code: "_DEL", name: "删除"},
            {code: "_MOD", name: "修改"}
        ];

        //事件
        $("#optAuthSaveBt").click(function () {
            var code = $("#optAuthForm").find("input[name=code]").val();
            var name = $("#optAuthForm").find("input[name=name]").val();
            if (!code) {
                alert("请输入前缀");
            } else {
                $.each(realName, function (i, n) {
                    var relCode = code + n.code;
                    var relName = name?n.name+name:n.name;
                    $.ajax({
                        url: ctx + "/optAuthAction/save.do",
                        async: false,
                        data: {funcPointId: funcPointId, name: relName, code: relCode},
                        success: function (data) {
                            if (data.success) {
                            } else {
                                webUtils.error(data.msg);
                            }
                        },
                        dataType: "json"
                    });

                });
                top.webUtils.topicPublish("optAuth.edit.success", null);
            }
        });
    });
</script>